﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core;
using Cofe.Core.Filter;
using Cofe.Core.Property;

namespace Cofe.Data.Filter
{
    [EntryFilter("tags")]
    public class TagsEntryFilter : EntryFilterBase
    {
        public TagsEntryFilter(string name, string id = "tags")
            : base(name, id)
        {
            SupportedMatchType = MatchType.MatchThisEntry;
        }

        public override MatchType matches(IPropertyHost entry,
           params IOptionFilter[] options)
        {            
            var tags =  entry.Behaviors.GetProperty<string>(UserFeedbackProperties.Tags).Split(',');
            bool match = tags.Contains(Value, StringComparer.InvariantCultureIgnoreCase);
            return match ? MatchType.MatchThisEntry : MatchType.None;
        }
    }
}
